﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="eBayCategoryManagement.aspx.cs" Inherits="NetDon.OA.Portal.HtmlTool.eBayCategoryManagement" %>
<%@ Import Namespace="NetDon.Utilities" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
        var userDialogSize = { width: 900, height: 650 };
        function createCustomer() {

            $dialog('<%=ResolveUrl("~/HtmlTool/eBayCategoryEdit.aspx") %>?Type=0', userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }

        function modifyCustomer(id) {
            $dialog('<%=ResolveUrl("~/HtmlTool/eBayCategoryEdit.aspx") %>?Type=0&Id=' + id, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }

        function deleteDemand(id) {
            $confirm('确定要删除吗?', function (result) {
                if (result) {
                    $text($get('<%=fieldCustomerId.ClientID %>'), id);
                    $get('<%=btnDeleteDemand.ClientID %>').click();
                }
            });
        }
        function setStyleDemand(id) {
            $dialog('<%=ResolveUrl("~/HtmlTool/StyleEdit.aspx") %>?CategoryRuleId=' + id, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }


        function viewCategory(sender, args) {
            var orderId = $attr(sender.get_selectedRow(), 'Id');
            $dialog('<%= ResolveUrl("~/HtmlTool/eBayCategoryEdit.aspx")%>?Id=' + orderId, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }



        function viewStyleSetting(sender, args) {
            var orderId = $attr(sender.get_selectedRow(), 'BatchId');
            var categoryRuleId = $attr(sender.get_selectedRow(), 'CategoryRuleId');
            $dialog('<%= ResolveUrl("~/HtmlTool/StyleEdit.aspx")%>?BatchId=' + orderId + '&CategoryRuleId=' + categoryRuleId, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }


        function modifyStyleSetting(batchId, categoryRuleId) {
            $dialog('<%=ResolveUrl("~/HtmlTool/StyleEdit.aspx") %>?BatchId=' + batchId + '&CategoryRuleId=' + categoryRuleId, userDialogSize, function (result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }


        function deleteStyleSetting(batchId) {
            $confirm('确定要删除吗?', function (result) {
                if (result) {
                    $text($get('<%=fieldCustomerId.ClientID %>'), batchId);
                    $get('<%=btnDeleteStyleSetting.ClientID %>').click();
                }
            });
        }
        


    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td>
                        <NetDon:FormPanel ID="PanelCondition" runat="server" CaptionAlign="NotSet" RepeatColumns="3">
                            <Items>
                            </Items>
                        </NetDon:FormPanel>
                    </td>
                    <td valign="bottom">
                        <asp:Button runat="server" ID="btnCreateNew" Text="创建" OnClientClick="createCustomer();return false;" />
                    </td>
                </tr>
            </table>
            <div style="margin-top: 10px">
                <NetDon:GridView ID="gridCustomerInfoList" runat="server" AutoGenerateColumns="False"
                    AllowSorting="true" DataKeyNames="Id" OnRowDetailCreated="gridCustomerInfoList_RowDetailCreated" OnClientRowDblClick="viewCategory"  OnRowDataBound="gridCustomerInfoList_RowDataBound">
                    <Columns>
                        <NetDon:IndexField HeaderText="序号">
                        </NetDon:IndexField>
                        <NetDon:BoundField HeaderText="规格包含" DataField="Rule" SortExpression="Rule">
                        </NetDon:BoundField>
                        <NetDon:BoundField HeaderText="HtmlTool产品分类" DataField="Category" SortExpression="Category">
                        </NetDon:BoundField>
                     
                        <NetDon:BoundField HeaderText="eBay分类号" DataField="Ebaycategory" SortExpression="Ebaycategory">
                        </NetDon:BoundField>
                        <NetDon:TemplateField HeaderText="操作" ItemStyle-Width="80px">
                            <ItemTemplate>
                                <asp:ImageButton ID="btnEdit" Style="margin-left: 5px" ToolTip="Edit" runat="server"
                                    CommandName="Edit" SkinID="Modify" ImageAlign="AbsMiddle" CausesValidation="false"
                                    OnClientClick='<%# Eval("Id","modifyCustomer(\"{0}\");return false;") %>' />
                                <asp:ImageButton ID="btnDelete" ToolTip="Delete" runat="server" SkinID="Delete" ImageAlign="AbsMiddle"
                                    CausesValidation="false" CommandName="DeleteCustomer" CommandArgument='<%# Eval("Id") %>'
                                    OnClientClick='<%# Eval("Id","deleteDemand(\"{0}\");return false;") %>' />
                                      <asp:ImageButton ID="btnSetStyle" ToolTip="设置款式" runat="server" SkinID="AddDisabled" ImageAlign="AbsMiddle"
                                    CausesValidation="false" CommandName="SetStyle" CommandArgument='<%# Eval("Id") %>'
                                    OnClientClick='<%# Eval("Id","setStyleDemand(\"{0}\");return false;") %>' />
                            </ItemTemplate>
                        </NetDon:TemplateField>
                    </Columns>
                    <DetailSettings HeaderText="款式" ColumnWidth="100px" CollapseText="隐藏" ExpandText="查看"
                        ExpandImageUrl="~/Images/Button/expand.jpg" CollapseImageUrl="~/Images/Button/collapse.jpg"
                        TargetControlID="pnlStyleSetting">
                    </DetailSettings>
                </NetDon:GridView>
                   <asp:Panel ID="pnlStyleSetting" runat="server" Visible="false" ScrollBars="None"
                BorderColor="White">
                <div style="width: 900px; overflow-x: auto;">
                    <asp:GridView ID="grdStyleSetting" BorderWidth="0px" CellPadding="0" CellSpacing="0"
                        Width="100%" AutoGenerateColumns="false" runat="server" OnClientRowDblClick="viewStyleSetting"
                        OnRowDataBound="grdStyleSetting_RowDataBound">
                        <Columns>
                            <asp:BoundField HeaderText="默认US站点" DataField="USValue" 
                                ></asp:BoundField>
                                 <asp:BoundField HeaderText="AU站点" DataField="AUValue" 
                               ></asp:BoundField>
                                 <asp:BoundField HeaderText="UK站点" DataField="UKValue" 
                              ></asp:BoundField>
                                 <asp:BoundField HeaderText="DE站点" DataField="DEValue" 
                                ></asp:BoundField>
                                 <asp:BoundField HeaderText="FR站点" DataField="FRValue" 
                                ></asp:BoundField>
                                 <asp:BoundField HeaderText="IT站点" DataField="ITValue" 
                               ></asp:BoundField>

                                    <asp:BoundField HeaderText="Site1" DataField="Site1Value" 
                                ></asp:BoundField>
                                    <asp:BoundField HeaderText="Site2" DataField="Site2Value" 
                                ></asp:BoundField>
                                    <asp:BoundField HeaderText="Site3" DataField="Site3Value" 
                                ></asp:BoundField>
                                    <asp:BoundField HeaderText="Site4" DataField="Site4Value" 
                                ></asp:BoundField>
                         
                            <asp:TemplateField HeaderText="操作" ItemStyle-Width="100px">
                                <ItemTemplate>
                                    <asp:ImageButton ID="btnEdit" Style="margin-left: 5px" ToolTip="Edit" runat="server"
                                    CommandName="Edit" SkinID="Modify" ImageAlign="AbsMiddle" CausesValidation="false"
                                     />
                                    <asp:ImageButton ID="btnDelete" runat="server" SkinID="Delete" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <HeaderStyle CssClass="test" />
                        <RowStyle CssClass="test" />
                        <AlternatingRowStyle CssClass="GridRow1" />
                    </asp:GridView>
                </div>
            </asp:Panel>
                <asp:Button ID="btnReload" runat="server" SkinID="Hidden" OnClick="btnReload_Click" />
                <asp:HiddenField ID="fieldCustomerId" runat="server" />
                <asp:Button ID="btnDeleteDemand" runat="server" OnClick="btnDeleteDemand_Click" Text="Delete"
                    SkinID="Hidden" />
                   <asp:Button ID="btnDeleteStyleSetting" runat="server" OnClick="btnDeleteStyleSetting_Click" Text="Delete"
                    SkinID="Hidden" />  
                    
                    
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>
        <script type="text/javascript">


            function pageLoad() {
                setTimeout(function () {
                    function showDetail(index) {
                        var grid = $find('<%=gridCustomerInfoList.ClientID%>');
                        if (grid._rows.length <= index) return;
                        var row = grid._rows[index];
                        var elements = row.getElementsByTagName("input"); //the last input is the details loading 
                        grid.showDetail(index, elements[elements.length - 1], function () {
                            showDetail(index + 1);
                        });
                    }

                    showDetail(0);

                }, 0);
            }

    </script>
</asp:Content>